import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { TDesignResolver } from 'unplugin-vue-components/resolvers'
import { viteMockServe } from 'vite-plugin-mock'
import eslintPlugin from 'vite-plugin-eslint'
// https://vitejs.dev/config/
export default ({ command }) => {
  return defineConfig({
    plugins: [
      vue(),
      AutoImport({
        resolvers: [TDesignResolver({
          library: 'vue-next'
        })]
      }),
      Components({
        resolvers: [TDesignResolver({
          library: 'vue-next'
        })]
      }),
      viteMockServe({
        mockPath: 'mock',
        localEnabled: command === 'serve'
      }),
      eslintPlugin()
    ],
    resolve: {
      alias: {
        '@': '/src'
      }
    },
    server: {
      port: 2020
    }
  })
}
